#默认从小到大进行排序
l1=sorted([14,5,21,-1,-100])
print(l1)
#自定义排序-比如按绝对值大小
l1=sorted([14,5,21,-1,-100],key=abs)
print(l1)

#字符串排序 大写字母的ascii码比小写字母的ascii码小
l1=sorted(['bob','about','oop','c++','Zdasd'])
print(l1)
#全部变小写在排序，进行字母排序
l1=sorted(['bob','about','oop','c++','Zdasd'],key=str.lower)
print(l1)
#reverse 反向排序,反字母排序
l1=sorted(['bob','about','oop','c++','Zdasd'],key=str.lower,reverse=True)
print(l1)

students = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)]

from operator import itemgetter
print(sorted(students, key=itemgetter(0)))
print(sorted(students, key=lambda t: t[1]))
print(sorted(students, key=itemgetter(1), reverse=True))


